package org.covalence.core;

import java.util.HashMap;
import java.util.Map;


public class ClassConfig {

	private Map<String, PropertyConfig> props = 
		new HashMap<String, PropertyConfig>();
	
	private String className;
	
	public ClassConfig(String className) {
		this.className = className;
	}

	public String getClassName() {
		return className;
	}

	public PropertyConfig getPropertyConfig(String property) {
		return props.get(property);
	}
	
	public void putPropertyConfig(PropertyConfig pc) {
		props.put(pc.getPropertyName(), pc);
	}
	
	public void putProperty(String propertyName, String fieldType) {
		putProperty(propertyName, fieldType, 
				Strings.propertyToAccessor("set", propertyName), null);
	}
	public void putProperty(String propertyName, String fieldType, 
			String methodName, String methodSignature) {
		
		PropertyConfig pc = props.get(propertyName); 
		if (pc == null)
			pc = new PropertyConfig();
		pc.setPropertyName(propertyName);
		pc.setTypeDescriptor(fieldType);
		pc.setMethodName(methodName);
		pc.setMethodSignature(methodSignature);

		props.put(propertyName, pc);
	}

	public Map<String, PropertyConfig> getPropertyConfigs() {
		return props;
	}
}
